<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>HA_Chat</title>
    <script type="text/javascript">
        // by zhengkai.blog.csdn.net
        var socket;

        if (!window.WebSocket) {
            window.WebSocket = window.MozWebSocket;
        }
        if (window.WebSocket) {
            index = new WebSocket("ws://127.0.0.1:8089/ws");
            index.onmessage = function (event) {
                var ta = document.getElementById('responseText');
                ta.value += event.data + "\r\n";
            };
            index.onopen = function (event) {
                var ta = document.getElementById('uid');
                ta.value = "";
            };
            index.onclose = function (event) {
                var ta = document.getElementById('responseText');
                ta.value = "Netty-WebSocket服务器。。。。。。关闭 \r\n";
            };
        } else {
            alert("您的浏览器不支持WebSocket协议！");
        }

        function send(message) {
            if (!window.WebSocket) {
                return;
            }
            if (index.readyState == WebSocket.OPEN) {
                index.send(message);
            } else {
                alert("WebSocket 连接没有建立成功！");
            }

        }

    </script>
</head>
<body>
<div>
    <form onSubmit="return false;">
        <div style="margin: 5px">
            <span style="width: 150PX;margin: 5px">BussessType:</span>
                <select  type="text" ID="BussessType" name="BussessType">
                    <option value="logging">logging</option>
                    <option value="send">send</option>
                    <option value="quit">quit</option>
                </select> <br/>
            <span style="width: 150PX;margin: 5px">NAME:</span>
                <input style="margin: 5px" type="text" ID="uid" name="uid" value="zhuqi" placeholder=""/> <br/>
            <span style="width: 150PX;margin: 5px">TEXT:</span>
                <input style="margin: 5px" type="text" name="message" value="123" placeholder=""/> <br/>
            <br/> <input type="button" value="发送ws消息" style="margin: 5px"
                         onClick="send(this.form.BussessType.value+ ' ' + this.form.uid.value+ ' ' +this.form.message.value)"/>
        </div>
        <div style=" border: 2px solid black ;width: 1050px;margin: 5px">
            <h3 style="margin: 5px">服务端返回的应答消息</h3>
            <textarea id="responseText" style="width: 1024px;height: 300px;margin-left: 1%;margin-bottom: 1%;"></textarea>
        </div>

        <div style="font-size: 10px;margin: 5px;color: red;">
            <p>登陆：logging username password ;发送消息：send username password ;退出：quit</p>
        </div>

    </form>
</div>

</body>
</html>